<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原型链继承</title>
</head>
<body>
    <script>
        function Animal (name) {
            this.name = name
        }
        Animal.prototype.say = function () {
            console.log('My name is ' + this.name)
        }

        function Dog () {
            
        }

        // 把子类的原型指向父类的实例
        Dog.prototype = new Animal('Snoopy')

        var snoopy = new Dog()
        snoopy.say()

        var orange = new Dog()
        orange.say()

        console.log(snoopy instanceof Dog) // true
        console.log(snoopy instanceof Animal) // true






    </script>
</body>
</html>